package com.jiazhong.basic.shuxin.thread.a;

import lombok.SneakyThrows;

import java.util.ArrayList;
import java.util.List;

public class DemoD {

    private int sum = 0;
    private List<Integer> list;

    public DemoD() {
        list = new ArrayList<>();
        for (int i = 0; i < 20; i++) {
            int num = (int) (Math.random() * 100 + 1);
            list.add(num);
        }
    }

    @SneakyThrows
    public void jisuan() {
        for (int i = 0; i < list.size(); i++) {
            sum += list.get(i);
            Thread.sleep(100);
        }
    }

    public int sum() {
        return sum;
    }
}
